<?php
use yii\helpers\Url;
?>
<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title>铝邦CRM--登录</title>
    <link rel="stylesheet" href="bootstrap/css/bootstrap.min.css"/>
    <link rel="stylesheet" href="css/common.css"/>
    <link rel="stylesheet" href="css/public.css"/>
    <link rel="stylesheet" href="css/setting.css"/>
    <script src="layui/layui.all.js"></script>
    <script src="js/jquery-1.12.3.min.js"></script>
</head>
<body class="login-bg">
    <div class="login-main">
        <h3 class="login-tittle">用户登录</h3>
        <form class="form-horizontal" action="<?=Url::toRoute(['admin/logindo'])?>" method="post">
            <div class="form-group login-div has-success col-sm-8">
                <div class="input-group">
                    <span class="input-group-addon"><span class="glyphicon glyphicon-user"></span></span>
                    <input  name="username" type="text" class="form-control login-input" placeholder="请输入用户名" id="username" >
                </div>

            </div>
            <div class="form-group login-div has-success has-feedback col-sm-8">
                <div class="input-group">
                    <span class="input-group-addon"><span class="glyphicon glyphicon-lock"></span></span>
                    <!--注意：密码输入ID不能修改-->
                    <input  id="login-password" name="password" type="password" class="form-control login-input" placeholder="请输入密码"  >
                </div>
                <span class="glyphicon glyphicon-eye-close eye-close-open" show-flag="0" id="password-show"></span>

            </div>
            <div class="form-group">
                <div class="col-sm-offset-2 col-sm-9">
                    <div class="checkbox">
                        <label>
                            <input type="checkbox">记住用户名
                        </label>
                    </div>
                </div>
            </div>
            <div class="form-group login-div">
                <div class="col-sm-8">
                    <input type="button" class="btn-login" value="立即登录" onclick="toLogin()">
                </div>
            </div>
        </form>
    </div>
    <script>
        $("#password-show").click(function () {

            var nowFlag = $("#password-show").attr("show-flag");

            if(nowFlag == 0){
                $("#login-password").attr("type","text");
                $("#password-show").attr("show-flag",1);
            }
            if(nowFlag == 1){
                $("#login-password").attr("type","password");
                $("#password-show").attr("show-flag",0);
            }
        });
        function toLogin(){
            var url="<?=Url::toRoute(['admin/logindo'])?>";
            var params={};
            params.username=$('#username').val();
            params.password=$('#login-password').val();
            $.post(url,params,function(data){
                var data=JSON.parse(data);
                if(data.errcode==0){
                    layer.msg(data.errmsg);
                    window.location.reload();
                }else{
                    layer.msg(data.errmsg);
                }
               // alert('sfssfd');
            });
        }


    </script>
</body>
</html>